import java.util.*;

abstract class Observer {

    protected Announcement subject;

    public abstract void update();
}

class Announcement {

    private List<Observer> observers = new ArrayList<Observer>();
    private int state;   
    private String announce;

    public String getState() {
        return "State is: " + state + " || Announcement: " + announce;
    }

    public void setState(int state, String announce) {
        this.state = state;
        this.announce = announce;
        notifyAllObservers();
    }

    public void attach(Observer observer) {
        observers.add(observer);
    }

    public void notifyAllObservers() {
        for (Observer observer : observers) {
            observer.update();
        }
    }
}

class TV extends Observer {

    public TV(Announcement subject) {
        this.subject = subject;
        this.subject.attach(this);
    }

    @Override
    public void update() {
        System.out.println("TV: " + subject.getState());
    }
}

class VK extends Observer {

    public VK(Announcement subject) {
        this.subject = subject;
        this.subject.attach(this);
    }

    @Override
    public void update() {
        System.out.println("VK: " + subject.getState());
    }
}

class SMS extends Observer {

    public SMS(Announcement subject) {
        this.subject = subject;
        this.subject.attach(this);
    }

    @Override
    public void update() {
        System.out.println("SMS: " + subject.getState());
    }
}

public class Task6 {

    public static void main(String[] args) {
        Announcement subject = new Announcement();

        new SMS(subject);
        new VK(subject);
        new TV(subject);       
        subject.setState(1,"NewS");        
        subject.setState(2,"Project");
    }
}
